package com.ruoyi.web.controller.xinfeng;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.daily.domain.XinfengCustomerQuotation;
import com.ruoyi.daily.service.IXinfengCustomerQuotationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报价单Controller
 * 
 * @author ruoyi
 * @date 2025-04-21
 */
@RestController
@RequestMapping("/dianlan/quotation")
public class XinfengCustomerQuotationController extends BaseController
{
    @Autowired
    private IXinfengCustomerQuotationService xinfengCustomerQuotationService;

    /**
     * 查询报价单列表
     */
    @PreAuthorize("@ss.hasPermi('dianlan:quotation:list')")
    @GetMapping("/list")
    public TableDataInfo list(XinfengCustomerQuotation xinfengCustomerQuotation)
    {
        startPage();
        List<XinfengCustomerQuotation> list = xinfengCustomerQuotationService.selectXinfengCustomerQuotationList(xinfengCustomerQuotation);
        return getDataTable(list);
    }

    /**
     * 导出报价单列表
     */
    @PreAuthorize("@ss.hasPermi('dianlan:quotation:export')")
    @Log(title = "报价单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XinfengCustomerQuotation xinfengCustomerQuotation)
    {
        List<XinfengCustomerQuotation> list = xinfengCustomerQuotationService.selectXinfengCustomerQuotationList(xinfengCustomerQuotation);
        ExcelUtil<XinfengCustomerQuotation> util = new ExcelUtil<XinfengCustomerQuotation>(XinfengCustomerQuotation.class);
        util.exportExcel(response, list, "报价单数据");
    }

    /**
     * 获取报价单详细信息
     */
    @PreAuthorize("@ss.hasPermi('dianlan:quotation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(xinfengCustomerQuotationService.selectXinfengCustomerQuotationById(id));
    }

    /**
     * 新增报价单
     */
    @PreAuthorize("@ss.hasPermi('dianlan:quotation:add')")
    @Log(title = "报价单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XinfengCustomerQuotation xinfengCustomerQuotation)
    {
        return toAjax(xinfengCustomerQuotationService.insertXinfengCustomerQuotation(xinfengCustomerQuotation));
    }

    /**
     * 修改报价单
     */
    @PreAuthorize("@ss.hasPermi('dianlan:quotation:edit')")
    @Log(title = "报价单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XinfengCustomerQuotation xinfengCustomerQuotation)
    {
        return toAjax(xinfengCustomerQuotationService.updateXinfengCustomerQuotation(xinfengCustomerQuotation));
    }

    /**
     * 删除报价单
     */
    @PreAuthorize("@ss.hasPermi('dianlan:quotation:remove')")
    @Log(title = "报价单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(xinfengCustomerQuotationService.deleteXinfengCustomerQuotationByIds(ids));
    }
}
